package com.hxgis.statisticanalysis.intelligentIndicator.controller;


import com.hxgis.statisticanalysis.intelligentIndicator.pojo.TicketModelType;
import com.hxgis.statisticanalysis.intelligentIndicator.service.TicketModelTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 赵恒
 * @date 2022/12/9
 */
@RestController
@RequestMapping("/statisticanalysis/frontapi/v1")
@Api(tags = "工单模型服务类型")
public class TicketModelTypeController {
    @Autowired
    TicketModelTypeService ticketModelTypeService;

    /**
     * 查询出所有的工单模型服务类型
     */
    @RequestMapping(value = "/ticketModelType/list", method = RequestMethod.GET)
    @ApiOperation("获取工单模型的服务类型")
    public List<TicketModelType> list() {
        return ticketModelTypeService.list();
    }

    @RequestMapping(value = "/ticketModelType/insert", method = RequestMethod.POST)
    @ApiOperation("新增工单模型的服务类型")
    public String insert(@RequestBody TicketModelType ticketModelType) {
        boolean b = ticketModelTypeService.save(ticketModelType);
        if (b) {
            return "添加成功";
        } else {
            throw new RuntimeException("添加失败");
        }
    }

    @RequestMapping(value = "/ticketModelType/update", method = RequestMethod.POST)
    @ApiOperation("修改工单模型的服务类型")
    public String update(@RequestBody TicketModelType ticketModelType) {
        boolean b = ticketModelTypeService.updateById(ticketModelType);
        if (b) {
            return "修改成功";
        } else {
            throw new RuntimeException("修改失败");
        }
    }

    @RequestMapping(value = "/ticketModelType/deleteById", method = RequestMethod.POST)
    @ApiOperation("删除工单模型的服务类型")
    public String delete(Integer id) {
        boolean b = ticketModelTypeService.removeById(id);
        if (b) {
            return "删除成功";
        } else {
            throw new RuntimeException("删除失败");
        }
    }
}
